{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import metrics\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "import time\n",
    "\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#读取数据\n",
    "import scipy.io as sio\n",
    "eventContMatrix = sio.mmread(\"EV_eventContMatrix\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.cluster import MiniBatchKMeans\n",
    "\n",
    "# 一个参数点（聚类数据为K）的模型，并评价聚类算法性能\n",
    "def K_cluster_analysis(K, df):\n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    km = MiniBatchKMeans(n_clusters = K)\n",
    "    km.fit(df)\n",
    "    \n",
    "    #保存预测结果\n",
    "    cluster_result = km.predict(df)\n",
    "\n",
    "    # K值的评估标准\n",
    "    #常见的方法有轮廓系数Silhouette Coefficient和Calinski-Harabasz Index\n",
    "    #这两个分数值越大则聚类效果越好\n",
    "    #CH_score = metrics.calinski_harabaz_score(X_train,mb_kmeans.predict(X_train))\n",
    "    CH_score = metrics.silhouette_score(df,cluster_result)   \n",
    "    print(\"CH_score: {}\".format(CH_score))\n",
    "\n",
    "    return CH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "CH_score: 0.143824722687\n",
      "K-means begin with clusters: 20\n",
      "CH_score: 0.146328994748\n",
      "K-means begin with clusters: 30\n",
      "CH_score: 0.131286352004\n",
      "K-means begin with clusters: 40\n",
      "CH_score: 0.141232724218\n",
      "K-means begin with clusters: 50\n",
      "CH_score: 0.13575883615\n",
      "K-means begin with clusters: 60\n",
      "CH_score: 0.149364932364\n",
      "K-means begin with clusters: 70\n",
      "CH_score: 0.128590559026\n",
      "K-means begin with clusters: 80\n",
      "CH_score: 0.142398789963\n",
      "K-means begin with clusters: 90\n",
      "CH_score: 0.128452846742\n",
      "K-means begin with clusters: 100\n",
      "CH_score: 0.136145425308\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "CH_scores = []\n",
    "Ks = [10,20,30,40,50,60,70,80,90,100]\n",
    "for K in Ks:\n",
    "    ch = K_cluster_analysis(K, eventContMatrix)\n",
    "    CH_scores.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.14382472268701407, 0.14632899474794517, 0.13128635200363126, 0.14123272421811367, 0.13575883614998735, 0.14936493236417403, 0.12859055902577127, 0.14239878996335703, 0.1284528467415719, 0.13614542530757512]\n"
     ]
    }
   ],
   "source": [
    "print CH_scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x6b5a160>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnX28lGW1978LNi+iooKICiqoGC+Dgm6QtxH3aOdomlqp\nByWztLQM00rN6mPnHKuTmJWa6ZG0NLfJMa2059Hs7BmFVEQ2giAisgWELSKgiKi8bbieP9bcD5vt\n3sw9e8/9NrO+n8/+DHPPPde1ZpiZ332tta61xDmHYRiGYXSK2gDDMAwjH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FmAlKgQbgblU5mejOW19HvoBq5qdV7L3xgQhYERkH+BR4Grn3AdR2xMVInImsNY5\nN7f54VZOrYS0tyrgeOAu59xI4CMqxD3UGnnf+NnAQOBQYG/ULdKSSvhs+CGw740JQoCISBdUDB50\nzv05f/gdb3mXv10blX0hMx44S0RWANNRd8Ct6HK3Kn9Of2B1NOaFSiPQ6Jybnb//CCoQlfrZOBVY\n7pxb55zbDvwZGEdlfjaa09bnoRE4rNl5JXtvTBACIu8fvxdY7Jz7ZbOHHgcuzv/7YuCxsG2LAufc\n951z/Z1zA9CAYc45Nxl4Gjg3f1pFvB/OuTXAKhH5VP7QKcCrVOhnA3UVjRGRHvnvjfd+VNxnowVt\nfR4eB76UzzYaA2z0XEsdxTamBYSITAD+CSxkl8/8B2gc4WHgcPSLcJ5zrmUwqawRkZOBa5xzZ4rI\nkeiKoRcwD/iic25rlPaFgYiMQIPrXYFlwFfQC7SK/GyIyH8C/4Zm580Dvor6xSvisyEiDwEno1VN\n3wH+HfgrrXwe8qJ5B5qV9DHwFedcfUnsMEEwDMMwwFxGhmEYRh4TBMMwDAMwQTAMwzDymCAYhmEY\ngAmCYRiGkccEwTAMwwBMEAzDMIw8JgiGYRgGAP8PVqjse+Zg4FkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1d1a5b00>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制不同聚类数目的模型的性能，找到最佳模型／参数（分数最高）\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
